﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GA.Server.ApiInfo
{
    [Serializable]
    public class ApiMission
    {
        public int Assists { get; private set; }
        public int CharacterId { get; private set; }
        public double DamageBot { get; private set; }
        public double DamagePlayer { get; private set; }
        public int Deaths { get; private set; }
        public double DefensePoints { get; private set; }
        public DateTime EndTime { get; private set; }
        public double Healing { get; private set; }
        public int Kills { get; private set; }
        public string MapName { get; private set; }
        public int MapInstanceId { get; private set; }
        public double ObjectivePoints { get; private set; }
        public int PlayerTaskForce { get; private set; }
        public bool PvpFlag { get; private set; }
        public double Score { get; private set; }
        public string Type { get; private set; }
        public int WinStatus { get; private set; }
        public int XpEarned { get; private set; }
        public int PlayerCount { get; private set; }
        public string WinningTaskForce { get; private set; }
        public string MapFriendlyName { get; private set; }
        public string Class { get; private set; }
        public int BotKills { get; private set; }
        public int PlayerKills { get; private set; }
        public int PlayerId { get; private set; }

        public ApiMission()
        {
        }

        public ApiMission(XmlReader reader)
        {
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "a:assists": Assists = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:character_id": CharacterId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:damage_bot": DamageBot = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:damage_player": DamagePlayer = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:deaths": Deaths = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:defense_pts": DefensePoints = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:endeddatetimeest": case "a:EndedDateTimeEST": EndTime = DateTime.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:healing": Healing = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:kills": Kills = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:mapName": MapName = ApiXmlNode.GetValue(reader); break;
                        case "a:map_friendly_name": MapFriendlyName = ApiXmlNode.GetValue(reader); break;
                        case "a:map_instance_id": MapInstanceId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:objective_pts": ObjectivePoints = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:playertaskforce": PlayerTaskForce = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:pvp_flag": PvpFlag = bool.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:score": Score = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:type": Type = ApiXmlNode.GetValue(reader); break;
                        case "a:winstatus": WinStatus = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:xp_earned": XpEarned = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:PlayerCount": PlayerCount = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:winning_taskforce": WinningTaskForce = ApiXmlNode.GetValue(reader); break;
                        case "a:class": Class = ApiXmlNode.GetValue(reader); break;
                        case "a:kills_bot": BotKills = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:kills_player": PlayerKills = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:player_id": PlayerId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                    }
                }
            }
        }
    }
}
